Skip to content

Comments

✨ Add overload for exec method to support text statement#1657

Open
YuriiMotov wants to merge 5 commits intofastapi:mainfrom
YuriiMotov:exec_overload_for_text_statement
Open

✨ Add overload for exec method to support text statement#1657
YuriiMotov wants to merge 5 commits intofastapi:mainfrom
YuriiMotov:exec_overload_for_text_statement

Conversation

@YuriiMotov
Copy link
Member

Currently session.exec(text("")) works, but leads to static type checker error:

error: No overload variant of "exec" of "Session" matches argument type "TextClause"  [call-overload]
note: Possible overload variants:
note:     def [_TSelectParam: Any] exec(self, statement: Select[_TSelectParam], *, params: Union[Mapping[str, Any], Sequence[Mapping[str, Any]], None] = ..., execution_options: Mapping[str, Any] = ..., bind_arguments: Optional[dict[str, Any]] = ..., _parent_execute_state: Optional[Any] = ..., _add_event: Optional[Any] = ...) -> TupleResult[_TSelectParam]
note:     def [_TSelectParam: Any] exec(self, statement: SelectOfScalar[_TSelectParam], *, params: Union[Mapping[str, Any], Sequence[Mapping[str, Any]], None] = ..., execution_options: Mapping[str, Any] = ..., bind_arguments: Optional[dict[str, Any]] = ..., _parent_execute_state: Optional[Any] = ..., _add_event: Optional[Any] = ...) -> ScalarResult[_TSelectParam]
note:     def exec(self, statement: UpdateBase, *, params: Union[Mapping[str, Any], Sequence[Mapping[str, Any]], None] = ..., execution_options: Mapping[str, Any] = ..., bind_arguments: Optional[dict[str, Any]] = ..., _parent_execute_state: Optional[Any] = ..., _add_event: Optional[Any] = ...) -> CursorResult[Any]

This PR adds overload for Session.exec and AsyncSession.exec to fix this.

Addresses #376

@YuriiMotov YuriiMotov added the feature New feature or request label Nov 26, 2025
@github-actions github-actions bot added the conflicts Automatically generated when a PR has a merge conflict label Feb 20, 2026
@github-actions
Copy link
Contributor

This pull request has a merge conflict that needs to be resolved.

@github-actions github-actions bot removed the conflicts Automatically generated when a PR has a merge conflict label Feb 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant